/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ihmprojet.view.onglets;

import ihmprojet.view.FenetrePrincipale;
import javax.swing.JTabbedPane;

/**
 *
 * @author thomas
 */
public class AjoutContextPanel extends javax.swing.JPanel implements boutonContextInterface {

    private FenetrePrincipale fenp;
    private JTabbedPane jTab;

    /**
     * Creates new form AjoutContextPane
     */
    public AjoutContextPanel(FenetrePrincipale fp, JTabbedPane jTabpaneGraph) {
        initComponents();
        fenp = fp;
        jTab = jTabpaneGraph;
    }

    public void remove() {
        jTab.remove(this);
    }
    private boolean active = true;

    @Override
    public void desactive() {
        active = false;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentShown(java.awt.event.ComponentEvent evt) {
                formComponentShown(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents

    private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown
        jTab.setSelectedIndex(jTab.getTabCount() - 1 - 2);
       if(active) fenp.addNewContext();

    }//GEN-LAST:event_formComponentShown
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables

    @Override
    public void active() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public String getId() {
        return "+";
    }
}
